import config from '@/config'

/**
 * 初始化地图加载
 * @returns {Promise<any>}
 */
export function initMap() {
    return new Promise(function (resolve, reject) {
        window.init = function() {
            resolve(window.qq)
        }
        let script = document.createElement("script")
        script.type = "text/javascript"
        script.src = "https://map.qq.com/api/js?v=2.exp&callback=init&libraries=place&key=" + config.mapKey
        script.onerror = reject
        document.head.appendChild(script)
    })
}